import type { App } from 'vue';

export default {
    install(app: App<Element>, options: { limit: number}) {
        const mytruncate = (str: string) => {
            if (str.length > options.limit) {
                return `${str.slice(0, options.limit)}...`;
            }

            return str;
        }

        app.config.globalProperties.$mytruncate = mytruncate;

        app.provide("plugins", { mytruncate }); //For <script setup> only
    }
}
